import React from 'react'
import { useSelector,useDispatch,connect } from 'react-redux';

const Home = (props) => {
    console.log(props);
    const list = useSelector(state=>state.home.list);
    const dispatch = useDispatch();
    const add = ()=>{
        dispatch({type:'add_item',payload: 200})
    }
    return (
        <div>
            首页<button onClick={add}>添加</button>
            <ul>
                {
                    list.map(item=><li>{item}</li>)
                }
            </ul>
        </div>
    )
}

// const mapStateToProps = state=>({list:state.home.list})
const mapStateToProps = state=>state.home;

export default connect(mapStateToProps)(Home)
